﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using YArchitech.Controls;

namespace YJKArch.DimensionModule
{
	public partial class DlgArrowDim : System.Windows.Forms.Form
	{
		public DlgArrowDim()
		{
			this.InitializeComponent();
		}

		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		private void DlgArrowDim_Load(object sender, EventArgs e)
		{
			Helper.AddCombItems(DimDate.FontFamily, this.cboFontType);
			Helper.AddCombItems(DimDate.ArrowType, this.cboArrowStyle);
			if (this.cboAlignStyle.Items.Count > 0)
			{
				this.cboAlignStyle.SelectedIndex = 0;
			}
		}

		private void DlgArrowDim_MouseLeave(object sender, EventArgs e)
		{
			if (!base.ClientRectangle.Contains(base.PointToClient(Cursor.Position)))
			{
				int wMsg = 7;
				DlgArrowDim.SendMessage(CmdArrowDim._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			}
			else
			{
				base.Focus();
			}
			this.arrowType = this.cboArrowStyle.SelectedItem.ToString();
			this.alignStyle = this.cboAlignStyle.SelectedItem.ToString();
			this.LineUpText = this.txtLineUp.Text;
			this.LineDownText = this.txtLineDown.Text;
			this.fontType = this.cboFontType.SelectedItem.ToString();
			this.lineUpRows = this.txtLineUp.Lines.Length;
			this.lineDownRows = this.txtLineDown.Lines.Length;
			if (this.txtLineUp.Text.Length > 0)
			{
				this.LineUpmaxLenth = Helper.ReadTextMaxLenth(this.txtLineUp);
			}
			if (this.txtLineDown.Text.Length > 0)
			{
				this.LineDownmaxLent = Helper.ReadTextMaxLenth(this.txtLineDown);
			}
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (this.checktxt)
			{
				YJKTextBox hytextBox = this.txtLineUp;
				hytextBox.Text += "°";
				return;
			}
			System.Windows.Forms.TextBox textBox = this.txtLineDown;
			textBox.Text += "°";
		}

		private void button2_Click(object sender, EventArgs e)
		{
			if (this.checktxt)
			{
				YJKTextBox hytextBox = this.txtLineUp;
				hytextBox.Text += "±";
				return;
			}
			System.Windows.Forms.TextBox textBox = this.txtLineDown;
			textBox.Text += "±";
		}

		private void button3_Click(object sender, EventArgs e)
		{
			if (this.checktxt)
			{
				YJKTextBox hytextBox = this.txtLineUp;
				hytextBox.Text += "φ";
				return;
			}
			System.Windows.Forms.TextBox textBox = this.txtLineDown;
			textBox.Text += "φ";
		}

		private void button4_Click(object sender, EventArgs e)
		{
			if (this.checktxt)
			{
				YJKTextBox hytextBox = this.txtLineUp;
				hytextBox.Text += "%";
				return;
			}
			System.Windows.Forms.TextBox textBox = this.txtLineDown;
			textBox.Text += "%";
		}

		private void txtLineUp_MouseClick(object sender, MouseEventArgs e)
		{
			this.checktxt = true;
		}

		private void txtLineDown_MouseClick(object sender, MouseEventArgs e)
		{
			this.checktxt = false;
		}

		private void ckbLinupMoreText_CheckedChanged(object sender, EventArgs e)
		{
			if (this.ckbLinupMoreText.Checked)
			{
				this.txtLineUp.Multiline = true;
				this.txtLineUp.ScrollBars = ScrollBars.Vertical;
				this.txtLineUp.Height = 42;
				base.Height += 21;
				return;
			}
			this.txtLineUp.Multiline = false;
			this.txtLineUp.ScrollBars = ScrollBars.None;
			base.Height -= 21;
		}

		private void ckbLineDownMoreText_CheckedChanged(object sender, EventArgs e)
		{
			if (this.ckbLineDownMoreText.Checked)
			{
				this.txtLineDown.Anchor = AnchorStyles.None;
				this.txtLineDown.Multiline = true;
				this.txtLineDown.ScrollBars = ScrollBars.Vertical;
				this.txtLineDown.Height = 42;
				base.Height += 21;
				if (this.ckbLinupMoreText.Checked)
				{
					this.txtLineDown.Location = new System.Drawing.Point(69, 96);
					this.lablinedown.Location = new System.Drawing.Point(12, 96);
					this.ckbLineDownMoreText.Location = new System.Drawing.Point(324, 99);
					return;
				}
				this.txtLineDown.Location = new System.Drawing.Point(69, 75);
				this.lablinedown.Location = new System.Drawing.Point(12, 75);
				this.ckbLineDownMoreText.Location = new System.Drawing.Point(324, 78);
				return;
			}
			else
			{
				this.txtLineDown.Anchor = AnchorStyles.Bottom;
				this.lablinedown.Anchor = AnchorStyles.Bottom;
				this.ckbLineDownMoreText.Anchor = AnchorStyles.Bottom;
				this.txtLineDown.Multiline = false;
				this.txtLineDown.ScrollBars = ScrollBars.None;
				base.Height -= 21;
				if (this.ckbLinupMoreText.Checked)
				{
					this.txtLineDown.Location = new System.Drawing.Point(69, 96);
					this.lablinedown.Location = new System.Drawing.Point(12, 96);
					this.ckbLineDownMoreText.Location = new System.Drawing.Point(324, 99);
					return;
				}
				this.txtLineDown.Location = new System.Drawing.Point(69, 75);
				this.lablinedown.Location = new System.Drawing.Point(12, 75);
				this.ckbLineDownMoreText.Location = new System.Drawing.Point(324, 78);
				return;
			}
		}

		private void cboAlignStyle_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (this.cboAlignStyle.SelectedItem.ToString() == "在线端")
			{
				this.txtLineDown.Enabled = false;
				this.ckbLineDownMoreText.Enabled = false;
			}
			else
			{
				this.txtLineDown.Enabled = true;
				this.ckbLineDownMoreText.Enabled = true;
			}
			this.alignStyle = this.cboAlignStyle.SelectedItem.ToString();
		}

		private void cboArrowStyle_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.arrowType = this.cboArrowStyle.SelectedItem.ToString();
		}

		private void button9_Click(object sender, EventArgs e)
		{
			DlgDictForm dlgDictForm = new DlgDictForm();
			if (dlgDictForm.ShowDialog(this) == DialogResult.OK)
			{
				if (this.checktxt)
				{
					YJKTextBox hytextBox = this.txtLineUp;
					hytextBox.Text += dlgDictForm.text;
					return;
				}
				System.Windows.Forms.TextBox textBox = this.txtLineDown;
				textBox.Text += dlgDictForm.text;
			}
		}

		private void txtLineUp_TextChanged(object sender, EventArgs e)
		{
			this.LineUpText = this.txtLineUp.Text;
			if (this.txtLineUp.Text.Length > 0)
			{
				this.LineUpmaxLenth = Helper.ReadTextMaxLenth(this.txtLineUp);
			}
		}

		private void txtLineDown_TextChanged(object sender, EventArgs e)
		{
			this.LineDownText = this.txtLineDown.Text;
			if (this.txtLineDown.Text.Length > 0)
			{
				this.LineDownmaxLent = Helper.ReadTextMaxLenth(this.txtLineDown);
			}
		}

		public string arrowType;

		public string fontType;

		public string alignStyle;

		public string LineUpText;

		public string LineDownText;

		public bool isCheckedShareLeader = true;

		public string LineUpmaxLenth;

		public string LineDownmaxLent;

		public string ckbfixAngleSelect;

		public bool ckbFixAngle;

		public bool isMorePointShareLine;

		public int lineUpRows = 1;

		public int lineDownRows = 1;

		public bool checktxt = true;
	}
}
